{extend name="$layout" /}
{block name="title"}
	{$title}
{/block}

{block name="top"}
    
    
    
{/block}

{block name="content"}
        {notempty name="topbtn"}
        {volist name="topbtn" id="btn"}
        <button class="{$btn.class}" type="button" onclick="app.url('{$btn.href}')">{$btn.title}</button>
        {/volist} 
        {/notempty}
        {notempty name="quicksearch"}
        <div class="col-xs-3 pull-right">
            <div class="input-group">
                <input class="form-control" id="keyword" type="text" placeholder="{$quicksearch.default|default='关健字'}">
                <span class="input-group-btn">
                    <button class="btn btn-default" type="button" id="quick_search"><i class="fa fa-search"></i> {$quicksearch.title|default='Search'}</button>
                    <input type="hidden" value="{$quicksearch.field}" id="field">
                </span>
            </div>

        </div> 
        {/notempty} 
        <table class="table table-striped">
            <thead>
            <tr>
                <th style="display:none">
                    <label class="css-input css-checkbox css-checkbox-primary remove-margin-t remove-margin-b">
                        <input type="checkbox" id="check-all"><span></span>
                    </label>
                </th>
                {notempty name="columns"}
                {volist name="columns" id="column"}
                <th>{$column.title|default=''|htmlspecialchars}</th>
                {/volist} 
                {/notempty}
            </tr>
            </thead>
            <tbody>
            {notempty name="datasource"}
             {volist name="datasource" id="row"}
            <tr id="{$row[$pid]}">
                <td style="display:none"><input class="ids" type="checkbox" name="id" value=""></td>
                {volist name="columns" id="column"}
                <td>{$row[$column['name']]|default=''}</td> 
                {/volist}
            </tr> 
            {/volist}  
            {/notempty} 
            </tbody>
        </table>
        {notempty name="pager"}
        <div>{$pager}</div>
        {/notempty}
{/block}
{block name="scripts"}
<script type="text/javascript">
    $(document).ready(function(){
        $('.switch_post').click(function () {
            var data={};
            data.checked    = this.checked;
            data.name       = $(this).attr("name");
            data.value      = $(this).attr("value");
            data.default    = $(this).attr("default");
            data.param      = $(this).attr("param");
            if(data.default!=''){
                app.post(data.default,data);
                return true;
            }else{
                return false;
            }
        });
        {notempty name="quicksearch"}
        $('#quick_search').click(function () {
            var keyword=$('#keyword').val();
            var field=$('#field').val();
            location.href='?keyword='+keyword+'&field='+field;
        })
        {/notempty}
    });
</script>
{/block}